﻿//--作者：曾同春
//--用途：根据商品编码带出随附单据
//--时间：2016-03-03

// add by zhanyong 获取出口随附单据字典 2015-11-10
//oldData:之前存在的数据
//controlstr:要比较编码串，分割的ABC...
//iefig:报关类型

function GetAccompanyDetails(oldData, controlstr, iefig) {
    var accompany;
    var code = "";
    if (iefig == 2) {//进口
        code = "bg_jinkoushangpinsuifudanzheng";
    } else if (iefig == 1) { //出口
        code = "bg_shangpinsuifudanzheng";
    }
    var goodscontrolarr = controlstr.split('');
    var griddata = oldData;
    var urlstr = encodeURI("../Share/GetJsonList?tablename=v_data_base_dictionary_detail&fieldnames=value,name&where=code='" + code + "'&searchField=''");
    $.ajax({
        url: urlstr,
        type: "post",
        cache: false,
        async: false,
        success: function (data) {
            var result = mini.decode(data);
            var controlarr = Enumerable.From(result).Select(function (x) { return x.value; }).ToArray();
            ///取交集
            var instersectresult = Enumerable.From(goodscontrolarr).Intersect(controlarr).ToArray();
            var control_noarr = Enumerable.From(griddata).Select(function (x) { return x.control_no; }).ToArray();
            //取补集
            accompany = Enumerable.From(instersectresult).Except(control_noarr).ToArray();
        }
    });
    return accompany;
}